/*
 * Utiles_Seguridad.java
 *
 * Created on 29 de julio de 2008, 02:55 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package administracion.helper;

import javax.swing.*;
import java.util.StringTokenizer;


/**
 *
 * @author Frank
 */
public class Utiles_Seguridad {
    
    /** Creates a new instance of Utiles_Seguridad */
    public Utiles_Seguridad() {
    }
    
    public static void habilitaComponente( AbstractButton absBtn, String tipoUser ){
        String linCmd = absBtn.getActionCommand();  
        StringTokenizer strTok = new StringTokenizer( linCmd, "|" );
        boolean ind = false;
                     
        while( strTok.hasMoreTokens() ){
            if( strTok.nextToken().equalsIgnoreCase( tipoUser ) ){
                ind = true;
                break;
            }          
        }
        
        if( ind ){
            absBtn.setEnabled( true );
        }else{
            absBtn.setEnabled( false );
        }        
    }
    
    public static boolean isHabilitado( AbstractButton absBtn, String tipoUser ){
        String linCmd = absBtn.getActionCommand();  
        StringTokenizer strTok = new StringTokenizer( linCmd, "|" );
                             
        while( strTok.hasMoreTokens() ){
            if( strTok.nextToken().equals( tipoUser ) ){
                return true;                
            }          
        }
        return false;        
    }    
    
    
}
